package com.comtime.entity;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.comtime.greendaodemo.NewInfo;
import com.comtime.smartkilimanjaro.R;

public class ConsultBaseAdapter extends BaseAdapter {
	private LayoutInflater mInflater;
	private Context mContext;
	private List<NewListInfo> mAppList = new ArrayList<NewListInfo>();
	private ListView mListView;

	public ConsultBaseAdapter(Context context, ListView listView,List<NewListInfo> newsLists) {
		mInflater = LayoutInflater.from(context);
		mContext = context;
		mListView = listView;
		mAppList = newsLists;
	}

	public void setmAppList(List<NewListInfo> list) {
		mAppList = list;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public Object getItem(int position) {
		return mAppList.get(position);
	}

	@Override
	public int getCount() {
		return mAppList==null?0:mAppList.size();
	}

	@Override
	public View getView(int position, View view, ViewGroup parent) {
		ViewHolder holder = null;
		if (view == null) {
			holder = new ViewHolder();
			view = LayoutInflater.from(parent.getContext()).inflate(
					R.layout.list_item_info, null);
			holder.image_title=(ImageView) view.findViewById(R.id.image_title);
			holder.tv_title = (TextView) view.findViewById(R.id.tv_title);
			holder.tv_content = (TextView) view.findViewById(R.id.tv_content);
			holder.tv_data=(TextView) view.findViewById(R.id.tv_data);
			holder.tv_good_num=(TextView) view.findViewById(R.id.tv_good_num);
			holder.tv_total_count=(TextView) view.findViewById(R.id.tv_total_count);
			view.setTag(holder);
		} else {
			holder = (ViewHolder) view.getTag();
		}
		NewListInfo info=mAppList.get(position);
		holder.tv_title.setText(info.getTitle()+"");
		holder.tv_content.setText(info.getContent()+"");
		holder.tv_data.setText(info.getAdd_time()+"");
		holder.tv_good_num.setText(info.getGood_num()+"");
		holder.tv_total_count.setText(info.getTotal_count()+"");
		Glide.with(mContext).load(info.getImage()).placeholder(R.drawable.icon_picture_one).error(R.drawable.icon_picture_one).into(holder.image_title);
		return view;
	}
};

   class ViewHolder {
	  TextView tv_title, tv_content,tv_good_num,tv_total_count,tv_data;
	  ImageView image_title;
  }
